﻿using System.Data.Entity;

using System.Linq;

using System.Collections.Generic;

using SIG.Model;
using SIG.Data;
using SIG.Data.UnitOfWork;
using SIG.Infrastructure.Cache;
using SIG.Infrastructure.Logging;
using System;

namespace SIG.Repository
{
    public class CategoryRepository : Repository<Category>, ICategoryRepository
    {
        IMainBCUnitOfWork _unitOfWork;
        private ICacheService _cacheService;
        public CategoryRepository(IMainBCUnitOfWork unitOfWork,  ICacheService cacheService)
            : base(unitOfWork)
        {
            if (unitOfWork == (IMainBCUnitOfWork)null)
                throw new ArgumentNullException("unitOfWork");
            if (cacheService == (ICacheService)null)
                throw new ArgumentNullException("cacheService");
            this._unitOfWork = unitOfWork;
            this._cacheService = cacheService;
        }

        //public Category GetByIdWithProducts(int Id)
        //{
        //    return this._dbset.Include(p => p.Products).Include(c=>c.ChildCategories).SingleOrDefault(c => c.Id == Id);
        //}

        //public IEnumerable<Category> GetCategoriesWithChild(ModelType modelType)
        //{
        //    return this._dbset.Include(c=>c.ChildCategories)
        //        .Where(m => m.ParentId == null && m.ModelType == modelType).OrderByDescending(m => m.Importance).ToList();
        //}

        //public IEnumerable<Category> GetActivedCategoriesWithChild(ModelType modelType)
        //{
        //    return this._dbset.Include(c => c.ChildCategories).Where(m => m.ParentId == null && m.Active && m.ModelType == modelType)
        //        .OrderByDescending(m => m.Importance).ToList();
        //}

        //public IEnumerable<Category> GetChildCategoriesWithParent(ModelType modelType)
        //{
        //    return this._dbset.Include(c=>c.ParentCategory).Where(m => m.ParentId > 0 && m.ModelType == modelType)
        //        .OrderByDescending(m => m.Importance).ToList();
        //}
    }
}
